package arts.spbu.testswing;

import javax.swing.*;
import java.awt.*;

/**
 * Created with IntelliJ IDEA.
 * User: pev67021
 * Date: 29.10.12
 * Time: 8:52
 */

public class RegCellRenderer2 extends JLabel implements ListCellRenderer<MatchEntry> {

    @Override
    public Component getListCellRendererComponent(
            JList<? extends MatchEntry> list,              // the list
            MatchEntry value,            // value to display
            int index,               // cell index
            boolean isSelected,      // is the cell selected
            boolean cellHasFocus)    // does the cell have focus
    {
        String s = value.toString();
        setText(s);
        if (isSelected) {
            setBackground(new Color(255, 255, 0));
            setForeground(list.getSelectionForeground());
        } else {
            setBackground(list.getBackground());
            setForeground(list.getForeground());
        }
        setEnabled(list.isEnabled());
        setFont(list.getFont());
        setOpaque(true);
        return this;
    }
}

